#pragma once

#include "effectbase.h"
#include <osg\Vec4>
#include "controlcenter_global.h"
#include <osg\NodeCallback>

namespace VrDataCore
{
	class TransformableActor;
}

namespace osg
{
	class Camera;
}

namespace ControlCenter
{
	class AttachObjectManipulator;
	class ManipulatorManager;
	class AttachObjectEffect;

	class AttachObjectUpdateCallback : public osg::NodeCallback
	{
	public:
		AttachObjectUpdateCallback(AttachObjectEffect* ef);
		~AttachObjectUpdateCallback(){} ;
		virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
	protected:
		AttachObjectEffect*				_ef ;
	};

	class CONTROLCENTER_EXPORT AttachObjectEffect:public VrDataCore::EffectBase
	{
	public:
		AttachObjectEffect(ManipulatorManager* mm,osg::Camera* camera);
	protected:
		~AttachObjectEffect();
	public:
		virtual void buildPropertyMap();
		virtual osg::ref_ptr<CoreBase::ActorBase> clone();
		virtual void apply(CoreBase::ActorBase* actor);
		virtual void unApply(CoreBase::ActorBase* actor);
		void update();
		void setInitial(const osg::Vec3& offset,int distance,int anglexy, int anglexz);
	private:
		ManipulatorManager*							_manipulatorManager;
		AttachObjectManipulator*					_attachObjectManipulator;
		VrDataCore::TransformableActor*				_transformActor;
		osg::ref_ptr<AttachObjectUpdateCallback>	_updateCallback;
		bool										_setupCallback;
		osg::Camera*								_attachObjectCamera;
		//osg::NodeCallback*							_attachObjectUsingCallback;
		int											_distance;
		int											_angleXY;
		int											_angleXZ;
		osg::Vec3									_offset;
	};
}